//思路：完全二叉树的节点个数


import java.util.*;
class TreeNode {
     int val;
     TreeNode left;
     TreeNode right;
     TreeNode() {}
     TreeNode(int val) { this.val = val; }
     TreeNode(int val, TreeNode left, TreeNode right) {
         this.val = val;
         this.left = left;
         this.right = right;
     }
 }



 public class Solution {
     public int countNodes(TreeNode root) {
       if(root==null) return 0;
       Queue<TreeNode> q=new LinkedList<>();
       q.offer(root);
       int sum=0;
       while(!q.isEmpty()){
           TreeNode t=q.poll();
           sum++;
        if(t.left!=null)   q.offer(t.left);
        if(t.left!=null)   q.offer(t.right);
       }
       return sum;
     }

}